package com.boatAnchorAssistant.service.repository.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.boatAnchorAssistant.pojo.entity.Notice;
import com.boatAnchorAssistant.service.mapper.NoticeMapper;
import com.boatAnchorAssistant.service.repository.in.NoticeRepository;
import nirvana.core.repository.Repository;
import org.springframework.stereotype.Service;
    import com.boatAnchorAssistant.pojo.dto.notice.*;
    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@Service
public class NoticeRepositoryImpl extends Repository< NoticeMapper , Notice> implements NoticeRepository {

private final NoticeMapper mapper;

public NoticeRepositoryImpl(NoticeMapper mapper) {
this.mapper = mapper;
}

    /**
    * 搜索通知
    * @param dto
    * @return
    */
    @Override
    public Page< Notice > selectNotice(SelectNoticeDto dto){

    return mapper.selectNotice(dto);
    }

@Override
public Map<Long, Notice> getMap(List<Long> ids){
    Map<Long, Notice> map = new HashMap<>();

    if (CollectionUtil.isNotEmpty(ids)) {
    List<Notice> list =listByIds(ids);
    if (CollectionUtil.isNotEmpty(list)) {
    map = list.stream().collect(Collectors.toMap(Notice::getId, pojo -> pojo));
    }
    }
    return map;
    }
}